// 检查表字段是否唯一

import { registerDecorator, ValidationOptions } from "class-validator";


export function IsComfirm(validationOptions?: ValidationOptions) {
  return function (object: any, propertyName: string) {
    registerDecorator({
      name: "isComfirm",
      target: object.constructor,
      propertyName: propertyName,
      constraints: [],
      options: validationOptions,
      validator: {
      async  validate(value: String, args: any) {
   
          return Boolean(value === args.object[`${args.property}_confirm`]);
        },
      },
    });
  };
}
  